package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

/**
 * Created with IDEA
 * author:ju bai
 * Date:2021/1/18
 * Time:18:16
 **/
public class AddOperation implements IOperation{

    @Override
    public void work(BookList bookList) {
        System.out.println("添加图书！");
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入图书名字：");
        String name = scanner.nextLine();
        System.out.println("请输入图书作者：");
        String author = scanner.nextLine();
        System.out.println("请输入图书价格：");
        int price = scanner.nextInt();
        System.out.println("请输入图书类型：");
        String type = scanner.next();

        Book book = new Book(name,author,price,type);
        int curSize = bookList.getSize();
        bookList.setBooks(curSize,book);
        bookList.setSize(curSize+1);
    }
}
